﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.Rivyer.Model;
using Com.Rivyer.BLL;

namespace Com.Rivyer.Web
{
    public partial class main : System.Web.UI.Page
    {
        private readonly userqueryinfoBll userqueryinfobll = new userqueryinfoBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            //非法操作验证
            if (Session["username"] == null
                || Session["username"].ToString().Trim().Length == 0)
            {
                Response.Write("<script>top.location='./login.aspx'</script>");
            }
            else
            {
                //初始化userinfo

                userqueryinfoModel userqueryinfomodel = userqueryinfobll.getModel(Session["username"].ToString());
                username.Text = userqueryinfomodel.username;
                createdate.Text = userqueryinfomodel.createdate.ToString();
                logincount.Text = userqueryinfomodel.logincount.ToString();
                if (int.Parse(logincount.Text) == 1)
                {
                    latestlogin.Text = "没有记录!";
                }
                else
                {
                    latestlogin.Text = userqueryinfomodel.latestlogin.ToString();
                }
                latestoperate.Text = userqueryinfomodel.latestoperate;
            }
        }

        public string GetShortDate(string date)
        {
            return DateTime.Parse(date).ToShortDateString();
        }
    }
}